//
//  LeaderboardCellHeadFromView.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/11.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "LeaderboardCellHeadFromView.h"

@implementation LeaderboardCellHeadFromView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self.rankingsImage addSubview:self.secondHead];// 第二名头像
        [self.rankingsImage addSubview:self.secondImage];// 第二名标签
        [self.rankingsImage addSubview:self.secondName];// 第二名名称
        [self.rankingsImage addSubview:self.secondPrice];// 第二名奖金
        [self.rankingsImage addSubview:self.firstHead];// 第一名头像
        [self.rankingsImage addSubview:self.firstImage];// 第一名标签
        [self.rankingsImage addSubview:self.fitstName];// 第一名名称
        [self.rankingsImage addSubview:self.firstPrice];// 第一名奖金
        [self.rankingsImage addSubview:self.thirdHead];// 第三名头像
        [self.rankingsImage addSubview:self.thirdImage];// 第三名标签
        [self.rankingsImage addSubview:self.thirdName];// 第三名名称
        [self.rankingsImage addSubview:self.thirdPrice];// 第三名奖金
        [self addSubview:self.leaderNameImage];// 排行榜名称
        [self addSubview:self.rankingsImage];// 前三名背景
        [self showLeaderboardCellHeadView];
    }
    return self;
}

- (void)showLeaderboardCellHeadView
{
    _leaderNameImage.sd_layout
    .topSpaceToView(self,kHeightScale(14))
    .leftSpaceToView(self,kWidthScale(61))
    .rightSpaceToView(self,kWidthScale(61))
    .heightIs(kHeightScale(22));
    
    _rankingsImage.sd_layout
    .topSpaceToView(self.leaderNameImage,kHeightScale(10))
    .leftSpaceToView(self,kWidthScale(10))
    .rightSpaceToView(self,kWidthScale(10))
    .heightIs(kHeightScale(109));
    
    _secondHead.sd_layout
    .topSpaceToView(self.rankingsImage,kHeightScale(12))
    .leftSpaceToView(self.rankingsImage,kWidthScale(20))
    .widthIs(kWidthScale(46))
    .heightIs(kHeightScale(46));
    
    _secondImage.sd_layout
    .topSpaceToView(self.secondHead,kHeightScale(-5))
    .leftSpaceToView(self.rankingsImage,kWidthScale(17))
    .widthIs(kWidthScale(51))
    .heightIs(kHeightScale(12));
    
    _secondName.sd_layout
    .topSpaceToView(self.secondImage,kHeightScale(10))
    .leftSpaceToView(self.rankingsImage,0)
    .widthIs(kWidthScale(83))
    .heightIs(kHeightScale(10));
    
    _secondPrice.sd_layout
    .topSpaceToView(self.secondName,kHeightScale(8))
    .leftEqualToView(self.secondName)
    .rightEqualToView(self.secondName)
    .heightIs(kHeightScale(10));
    
    _firstHead.sd_layout
    .topSpaceToView(self.rankingsImage,kHeightScale(0))
    .leftSpaceToView(self.secondHead,kWidthScale(35))
    .widthIs(kWidthScale(60))
    .heightIs(kHeightScale(60));
    
    _firstImage.sd_layout
    .topSpaceToView(self.firstHead,kHeightScale(-5))
    .leftSpaceToView(self.secondImage,kWidthScale(28))
    .widthIs(kWidthScale(66))
    .heightIs(kHeightScale(14));
    
    _fitstName.sd_layout
    .topSpaceToView(self.firstImage,kHeightScale(6))
    .leftSpaceToView(self.secondName,kWidthScale(3))
    .widthIs(kWidthScale(83))
    .heightIs(kHeightScale(10));
    
    _firstPrice.sd_layout
    .topSpaceToView(self.fitstName,kHeightScale(8))
    .leftEqualToView(self.fitstName)
    .rightEqualToView(self.fitstName)
    .heightIs(kHeightScale(10));
    
    _thirdHead.sd_layout
    .topSpaceToView(self.rankingsImage,kHeightScale(12))
    .leftSpaceToView(self.firstHead,kWidthScale(28))
    .rightSpaceToView(self.rankingsImage,kWidthScale(17))
    .heightIs(kHeightScale(46));
    
    _thirdImage.sd_layout
    .topSpaceToView(self.thirdHead,kHeightScale(-5))
    .leftSpaceToView(self.firstImage,kWidthScale(25))
    .widthIs(kWidthScale(51))
    .heightIs(12);
    
    _thirdName.sd_layout
    .topSpaceToView(self.thirdImage,kHeightScale(10))
    .leftSpaceToView(self.fitstName,kWidthScale(0))
    .rightSpaceToView(self.rankingsImage,0)
    .heightIs(kHeightScale(10));
    
    _thirdPrice.sd_layout
    .topSpaceToView(self.thirdName,kHeightScale(8))
    .leftEqualToView(self.thirdName)
    .rightEqualToView(self.thirdName)
    .heightIs(kHeightScale(10));
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

// 排行榜名称
- (UIImageView *)leaderNameImage
{
    if (!_leaderNameImage)
    {
        _leaderNameImage = [[UIImageView alloc] init];
        _leaderNameImage.image = [UIImage imageNamed:@"bang"];
        
    }
    return _leaderNameImage;
}
// 前三名背景
- (UIImageView *)rankingsImage
{
    if (!_rankingsImage)
    {
        _rankingsImage = [[UIImageView alloc] init];
        _rankingsImage.image = [UIImage imageNamed:@"bg_qiansanming"];
        
    }
    return _rankingsImage;
}
// 第二名头像
- (UIButton *)secondHead
{
    if (!_secondHead)
    {
        _secondHead = [UIButton buttonWithType:UIButtonTypeCustom];
        [_secondHead setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:0];
        _secondHead.layer.cornerRadius = 12;
        _secondHead.layer.masksToBounds = YES;
    }
    return _secondHead;
}
// 第二名标签
- (UIImageView *)secondImage
{
    if (!_secondImage)
    {
        _secondImage = [[UIImageView alloc] init];
        _secondImage.image = [UIImage imageNamed:@"NO.2"];
    }
    return _secondImage;
}
// 第二名名称
- (UILabel *)secondName
{
    if (!_secondName)
    {
        _secondName = [[UILabel alloc] init];
        _secondName.text = @"林心如";
        _secondName.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _secondName.textColor = [UIColor blackColor];
        _secondName.textAlignment = NSTextAlignmentCenter;
    }
    return _secondName;
}
// 第二名奖金
- (UILabel *)secondPrice
{
    if (!_secondPrice)
    {
        _secondPrice = [[UILabel alloc] init];
        _secondPrice.text = @"¥100.0";
        _secondPrice.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _secondPrice.textColor = [UIColor redColor];
        _secondPrice.textAlignment = NSTextAlignmentCenter;
    }
    return _secondPrice;
}
// 第一名头像
- (UIButton *)firstHead
{
    if (!_firstHead)
    {
        _firstHead = [UIButton buttonWithType:UIButtonTypeCustom];
        [_firstHead setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:0];
        _firstHead.layer.cornerRadius = 12;
        _firstHead.layer.masksToBounds = YES;
    }
    return _firstHead;
}
// 第一名标签
- (UIImageView *)firstImage
{
    if (!_firstImage)
    {
        _firstImage = [[UIImageView alloc] init];
        _firstImage.image = [UIImage imageNamed:@"NO.1"];
    }
    return _firstImage;
}
// 第一名名称
- (UILabel *)fitstName
{
    if (!_fitstName)
    {
        _fitstName =[[UILabel alloc] init];
        _fitstName.text = @"迪丽热巴";
        _fitstName.textColor = [UIColor blackColor];
        _fitstName.font = [UIFont systemFontOfSize:kWidthScale(14)];
        _fitstName.textAlignment = NSTextAlignmentCenter;
    }
    return _fitstName;
}
// 第一名奖金
- (UILabel *)firstPrice
{
    if (!_firstPrice)
    {
        _firstPrice = [[UILabel alloc] init];
        _firstPrice.text = @"¥100.0";
        _firstPrice.textColor = [UIColor redColor];
        _firstPrice.font = [UIFont systemFontOfSize:kWidthScale(14)];
        _firstPrice.textAlignment = NSTextAlignmentCenter;
    }
    return _firstPrice;
}
// 第三名头像
- (UIButton *)thirdHead
{
    if (!_thirdHead)
    {
        _thirdHead = [UIButton buttonWithType:UIButtonTypeCustom];
        [_thirdHead setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:0];
        _thirdHead.layer.cornerRadius = 12;
        _thirdHead.layer.masksToBounds = YES;
    }
    return _thirdHead;
}
// 第三名标签
- (UIImageView *)thirdImage
{
    if (!_thirdImage)
    {
        _thirdImage = [[UIImageView alloc] init];
        _thirdImage.image = [UIImage imageNamed:@"NO.3"];
    }
    return _thirdImage;
}
// 第三名名称
- (UILabel *)thirdName
{
    if (!_thirdName)
    {
        _thirdName = [[UILabel alloc] init];
        _thirdName.text = @"赵薇";
        _thirdName.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _thirdName.textColor = [UIColor blackColor];
        _thirdName.textAlignment = NSTextAlignmentCenter;
    }
    return _thirdName;
}
// 第三名奖金
- (UILabel *)thirdPrice
{
    if (!_thirdPrice)
    {
        _thirdPrice = [[UILabel alloc] init];
        _thirdPrice.text = @"¥100.0";
        _thirdPrice.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _thirdPrice.textColor = [UIColor redColor];
        _thirdPrice.textAlignment = NSTextAlignmentCenter;
    }
    return _thirdPrice;
}

@end
